#ifndef __EXTI_H
#define	__EXTI_H

#include  "stm32f0xx.h"

//A相过零点探测引脚定义
/*******************************************************/
#define A_PHASE_INT_GPIO_PORT                GPIOB
#define A_PHASE_INT_GPIO_CLK                 RCC_AHBPeriph_GPIOB
#define A_PHASE_INT_GPIO_PIN                 GPIO_Pin_2
#define A_PHASE_INT_EXTI_PORTSOURCE          EXTI_PortSourceGPIOB
#define A_PHASE_INT_EXTI_PINSOURCE           EXTI_PinSource2
#define A_PHASE_INT_EXTI_LINE                EXTI_Line2
#define A_PHASE_INT_EXTI_IRQ                 EXTI2_3_IRQn

#define A_PHASE_IRQHandler                   EXTI2_3_IRQHandler

/*******************************************************/

//B相过零点探测引脚定义
/*******************************************************/
#define B_PHASE_INT_GPIO_PORT                GPIOB
#define B_PHASE_INT_GPIO_CLK                 RCC_AHBPeriph_GPIOB
#define B_PHASE_INT_GPIO_PIN                 GPIO_Pin_1
#define B_PHASE_INT_EXTI_PORTSOURCE          EXTI_PortSourceGPIOB
#define B_PHASE_INT_EXTI_PINSOURCE           EXTI_PinSource1
#define B_PHASE_INT_EXTI_LINE                EXTI_Line1
#define B_PHASE_INT_EXTI_IRQ                 EXTI0_1_IRQn

#define B_PHASE_IRQHandler                   EXTI0_1_IRQHandler

/*******************************************************/

//A相过零点探测引脚定义
/*******************************************************/
#define C_PHASE_INT_GPIO_PORT                GPIOB
#define C_PHASE_INT_GPIO_CLK                 RCC_AHBPeriph_GPIOB
#define C_PHASE_INT_GPIO_PIN                 GPIO_Pin_0
#define C_PHASE_INT_EXTI_PORTSOURCE          EXTI_PortSourceGPIOB
#define C_PHASE_INT_EXTI_PINSOURCE           EXTI_PinSource0
#define C_PHASE_INT_EXTI_LINE                EXTI_Line0
#define C_PHASE_INT_EXTI_IRQ                 EXTI0_1_IRQn

#define C_PHASE_IRQHandler                   EXTI0_1_IRQHandler 

/*******************************************************/
#define A_PHASE_INDICATOR_TOGGLE                      (GPIOB->ODR^=GPIO_Pin_10)
#define B_PHASE_INDICATOR_TOGGLE                      (GPIOB->ODR^=GPIO_Pin_11)
#define C_PHASE_INDICATOR_TOGGLE                      (GPIOB->ODR^=GPIO_Pin_12)

extern uint16_t A_Phase_Rising_Edge_To_Zero_Point;
extern uint16_t B_Phase_Rising_Edge_To_Zero_Point;
extern uint16_t C_Phase_Rising_Edge_To_Zero_Point;

void EXTI_ABC_Phase_Config(void);
void Indicator_Pin_Config(void);

#endif /* __EXTI_H */
